function [ zRank ] = buildHOML( X1, Y1, Tk, Tg, Th, pc, algorithm0 )
%BUILDHOML Summary of this function goes here
%   Detailed explanation goes here

% test = (indices == foldnum);
% train = ~test;
train_input = X1;
train_target = Y1;
% test_input = data(test,:);
% test_target = targets(test,:);
% u_target = train_target;
% v_target = test_target;

% Divide the training data into two parts by 2:1, 2 for training, 1 for validation.
num = size(train_input,1);
[train_t,train_v] = crossvalind('HoldOut',num,0.33);
train_t_input = train_input(train_t,:);     %Traning Set
train_v_input = train_input(train_v,:);     %Validation Set
train_t_target = train_target(train_t,:);   %Traning label
train_v_target = train_target(train_v,:);   %Validation Label

[ FS ] = InitIndividual(train_input);  %Initialize the 100 feature subsets

%Simulated Annealing
[ FS,E ] = SA( FS,Tk,train_t_input,train_v_input,train_t_target,train_v_target, algorithm0);

%Genetic algorithm
[ FS,E ] = GA( FS,E,Tg,pc,train_t_input,train_v_input,train_t_target,train_v_target, algorithm0);

%Hill climbing to make further optimizaiton based on the previous two stages.
[EF,I] = max(E);  %EF
FN = FS(I,:);     %Best Feature-subset until now.

Tp = Th;
while Tp > 0
    [BF,BEF,Tc] = HC(FN,EF,Tp,train_t_input,train_v_input,train_t_target,train_v_target, algorithm0);
    FN = BF;
    EF = BEF;
    Tp = Tc;
end

din = find(BF);
zRank = din;
% BF_Final = [BF_Final;BF];
% u = train_input(:,din);
% v = test_input(:,din);

end

